package com.jm.jisho.ocr;

import android.graphics.Bitmap;
import android.graphics.Matrix;

public class RotateBitmap
{
  public static final String TAG = "RotateBitmap";
  private Bitmap mBitmap;
  private int mRotation;

  public RotateBitmap(Bitmap paramBitmap)
  {
    this.mBitmap = paramBitmap;
    this.mRotation = 0;
  }

  public RotateBitmap(Bitmap paramBitmap, int paramInt)
  {
    this.mBitmap = paramBitmap;
    this.mRotation = (paramInt % 360);
  }

  public Bitmap getBitmap()
  {
    return this.mBitmap;
  }

  public int getHeight()
  {
    int i;
    if (!(isOrientationChanged()))
      i = this.mBitmap.getHeight();
    else
      i = this.mBitmap.getWidth();
    return i;
  }

  public Matrix getRotateMatrix()
  {
    Matrix localMatrix = new Matrix();
    if (this.mRotation != 0)
    {
      int i = this.mBitmap.getWidth() / 2;
      int j = this.mBitmap.getHeight() / 2;
      localMatrix.preTranslate(-i, -j);
      localMatrix.postRotate(this.mRotation);
      localMatrix.postTranslate(getWidth() / 2, getHeight() / 2);
    }
    return localMatrix;
  }

  public int getRotation()
  {
    return this.mRotation;
  }

  public int getWidth()
  {
    int i;
    if (!(isOrientationChanged()))
      i = this.mBitmap.getWidth();
    else
      i = this.mBitmap.getHeight();
    return i;
  }

  public boolean isOrientationChanged()
  {
	boolean i;
    if (this.mRotation / 90 % 2 == 0)
      i = false;
    else
      i = true;
    return i;
  }

  public void recycle()
  {
    if (this.mBitmap != null)
    {
      this.mBitmap.recycle();
      this.mBitmap = null;
    }
  }

  public void setBitmap(Bitmap paramBitmap)
  {
    this.mBitmap = paramBitmap;
  }

  public void setRotation(int paramInt)
  {
    this.mRotation = paramInt;
  }
}